sortlistmodel: Properly compute runs
authorBenjamin Otte <otte@redhat.com>
Tue, 21 Jul 2020 02:50:05 +0000 (04:50 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 22 Jul 2020 12:30:49 +0000 (14:30 +0200)
commitbf5c5403575c9f84308d0bfda9549ef0903a5bad
tree3ec3aded2d197a516e580372c15be1f885b5714a
parentc03383d3e5796e00ff167a44fdc5b0ff88bedf49
sortlistmodel: Properly compute runs

When updating a (partially) sorted model, take the known runs for the
existing sort and apply them to the new sort. That way, we don't have to
check the whole model again.

Benchmarks:

      appending half the items to a model of strings
                        old      new
      512,000 items   437ms    389ms
    1,024,000 items  1006ms    914ms

      appending 10% of the items to a model of strings
                        old      new
      512,000 items   206ms    132ms
    1,024,000 items   438ms    301ms

      appending 1 item to a model of strings
                        old      new
       64,000 items   1.8ms   0.00ms
      512,000 items     ---   0.01ms
gtk/gtksortlistmodel.c